import * as actionTypes from '@/app/Models/actions/actionTypes'
import { update } from '@/utils/helpers'

const initialState = {
    isRegisterError: false,
    errorMessage: '',
    userInfo: null,
    authRedirectPath: '/'
}

const authRegister = (state, action) => {
    return update(state, action)
}

const authRegisterError = (state, action) => {
    return update(state, action)
}

// 合并所有的请求
const reducer = ( state = initialState, action ) => {
    switch ( action.type ) {
        case actionTypes.REGISTER_USER_SAVE: 
            return authRegister(state, action)
        case actionTypes.REGISTER_ERROR:
            return authRegisterError(state, action)
        default:
            return state;
    }
};

export default reducer;